﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace eTMS.Forms.Reports
{
    public partial class FrmHtmlReportView : Form
    {
        public FrmHtmlReportView()
        {
            InitializeComponent();
        }

        private string _ReportFile = "";
        private DataTable tblData;
        public void SetDataSource(DataTable table, string ReportFile)
        {
            tblData = table;
            _ReportFile = ReportFile;
        }
        public void AddReportParameter(string ParamName,object Value)
        {
            htmlReportViewer1.ReportDocument.AddParameter(ParamName,Value);
        }
        private  void ShowReport()
        {
            if (tblData == null) return;
            if(tblData.DataSet==null)
            {
                DataSet ds=new DataSet();
                ds.Tables.Add(tblData);
            }
            SystemControllers.ReportHelper.AddHtmlReportParams(htmlReportViewer1.ReportDocument.Parameters);
            htmlReportViewer1.LoadReport(SystemControllers.ReportHelper.GetReportPath(_ReportFile));
            htmlReportViewer1.ReportDocument.DataSource = tblData.DataSet;
            htmlReportViewer1.ShowReport();
            htmlReportViewer1.ReportDocument.PageHeight = 400;
        }

        private void FrmHtmlReportView_Load(object sender, EventArgs e)
        {
            ShowReport();
        }
    }
}
